﻿Imports Model.Geometry

Namespace Midline
    ''' <summary>
    ''' 隧道中线的通用类
    ''' </summary>
    ''' <remarks></remarks>
    Public Class midline
        Private _id As Integer
        Private _LineType As LineTypeList        '中线段类型
        Private _startpt As Point3d                     '中线段起点
        Private _startOri As SingleVector           '中线段起点方向
        Private _startm As Double                       '中线段起点里程
        Private _endpt As Point3d                   '中线段终点
        Private _endOri As SingleVector          '中线段终点方向
        Private _endm As Double                     '中线段终点里程

        Private _length As Double                       '中线段长度，针对圆曲线和缓和曲线
        Private _isturnright As Boolean             '前进方向的转向，针对圆曲线和缓和曲线

        Private _midpt As Point3d                    '中线段曲中点，QZ,针对圆曲线
        Private _midm As Double                     '中线段中点里程，针对圆曲线
        Private _radius As Double                   '中线段曲率半径，针对圆曲线

        Private _startRadius As Double              '中线段起点曲率半径，针对缓和曲线
        Private _endRadius As Double             '中线段终点曲率半径，针对缓和曲线

        Private _startoffset As Double               '线路中心与隧道中心之间的偏移量(起点)
        Private _endoffset As Double                '线路中心与隧道中心之间的偏移量(终点)

        Public Property id() As Integer
            Get
                Return _id
            End Get
            Set(value As Integer)
                _id = value
            End Set
        End Property

        Public Property LineType() As LineTypeList
            Get
                Return _LineType
            End Get
            Set(value As LineTypeList)
                _LineType = value
            End Set
        End Property

        Public Property startpt() As Point3d
            Get
                Return _startpt
            End Get
            Set(value As Point3d)
                _startpt = value
            End Set
        End Property

        Public Property startOri() As SingleVector
            Get
                Return _startOri
            End Get
            Set(value As SingleVector)
                _startOri = value
            End Set
        End Property

        Public Property startm() As Double
            Get
                Return _startm
            End Get
            Set(value As Double)
                _startm = value
            End Set
        End Property

        Public Property endpt() As Point3d
            Get
                Return _endpt
            End Get
            Set(value As Point3d)
                _endpt = value
            End Set
        End Property

        Public Property endOri() As SingleVector
            Get
                Return _endOri
            End Get
            Set(value As SingleVector)
                _endOri = value
            End Set
        End Property

        Public Property endm() As Double
            Get
                Return _endm
            End Get
            Set(value As Double)
                _endm = value
            End Set
        End Property

        Public Property length() As Double
            Get
                Return _length
            End Get
            Set(value As Double)
                _length = value
            End Set
        End Property

        Public Property isturnright() As Boolean
            Get
                Return _isturnright
            End Get
            Set(value As Boolean)
                _isturnright = value
            End Set
        End Property

        Public Property midpt() As Point3d
            Get
                Return _midpt
            End Get
            Set(value As Point3d)
                _midpt = value
            End Set
        End Property

        Public Property midm() As Double
            Get
                Return _midm
            End Get
            Set(value As Double)
                _midm = value
            End Set
        End Property

        Public Property radius() As Double
            Get
                Return _radius
            End Get
            Set(value As Double)
                _radius = value
            End Set
        End Property

        Public Property startRadius() As Double
            Get
                Return _startRadius
            End Get
            Set(value As Double)
                _startRadius = value
            End Set
        End Property

        Public Property endRadius() As Double
            Get
                Return _endRadius
            End Get
            Set(value As Double)
                _endRadius = value
            End Set
        End Property

        Public Property startoffset() As Double
            Get
                Return _startoffset
            End Get
            Set(value As Double)
                _startoffset = value
            End Set
        End Property

        Public Property endoffset() As Double
            Get
                Return _endoffset
            End Get
            Set(value As Double)
                _endoffset = value
            End Set
        End Property

        Public Sub New()
            id = 0
            LineType = LineTypeList.TypeLINE
            startpt = New Point3d()
            startOri = New SingleVector()
            startm = 0
            endpt = New Point3d()
            endm = 0
            endOri = New SingleVector()
            length = 0
            isturnright = True
            midpt = New Point3d()
            midm = 0
            radius = 0
            startRadius = 0
            endRadius = 0
            startoffset = 0
            endoffset = 0
        End Sub
        ''' <summary>
        ''' 通用中线转直线
        ''' </summary>
        ''' <param name="L"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ConToL(ByVal L As Mid_Line)
            L.startpt = startpt
            L.startOri = startOri
            L.startm = startm
            L.endpt = endpt
            L.endOri = endOri
            L.endm = endm
            L.initMyself()
            Return Nothing
        End Function
        ''' <summary>
        ''' 通用中线转圆曲线
        ''' </summary>
        ''' <param name="C"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ConToC(ByVal C As Mid_Circle)
            C.startpt = startpt
            C.startOri = startOri
            C.startm = startm
            C.endpt = endpt
            C.endOri = endOri
            C.endm = endm
            C.isturnright = isturnright
            C.length = length
            C.radius = radius
            C.midpt = midpt
            C.midm = midm
            C.offset = startoffset
            Return Nothing
        End Function
        ''' <summary>
        ''' 通用中线转缓和曲线
        ''' </summary>
        ''' <param name="SC"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ConToSC(ByVal SC As Mid_SuperCircle)
            SC.startpt = startpt
            SC.startOri = startOri
            SC.startm = startm
            SC.endpt = endpt
            SC.endOri = endOri
            SC.endm = endm
            SC.isturnright = isturnright
            SC.length = length
            SC.endRadius = endRadius
            SC.startRadius = startRadius
            SC.startoffset = startoffset
            SC.endoffset = endoffset
            Return Nothing
        End Function

        'Shared Function LineTypeList() As Object
        '    Throw New NotImplementedException
        'End Function

    End Class
End Namespace
